﻿'' GoogleCode - http://code.google.com/p/outlook-4-you/
'' GNU GPL v3 Licencing

Public Class CSV
    Private fileLineArray As String()
    Public Sub New(ByVal path As String)
        Try
            fileLineArray = System.IO.File.ReadAllLines(path)
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        End Try
    End Sub
    Public Function Read(ByVal count As Integer) As String()()
        Dim fileContentArray(fileLineArray.Length - 1)() As String
        Try
            Dim i As Integer = 0
            For i = 0 To fileLineArray.Length - 1
                Dim line As String = fileLineArray(i)
                Dim delim As Char() = {","}
                fileContentArray(i) = line.Split(delim, count)
            Next
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        End Try
        Return fileContentArray
    End Function
    Public Function Write(ByVal path As String) As Boolean
        Try
            Dim sw As System.IO.StreamWriter = New System.IO.StreamWriter(path)
            For i = 0 To frmRequest.catalogue.Length - 1
                Dim line As String = frmRequest.catalogue(i)(0).ToString & "," & _
                                     frmRequest.catalogue(i)(1).ToString & "," & _
                                     frmRequest.catalogue(i)(2).ToString & "," & _
                                     frmRequest.catalogue(i)(3).ToString

                sw.WriteLine(line)
            Next
            sw.Flush()
            sw.Close()
            Return True
        Catch ex As Exception
            MsgBox("Unable to save CSV file")
            Return False
        End Try
    End Function
End Class
